var empty = '';

function credentials(obj){
	var button = document.getElementById('button');
	button.focus();
	button.click();
}

function validate(component) {
	if(component.value.length == 0) { 
		component.focus(); 
		return false; 
	}
	if(component.id == 'username'){
		document.getElementById('password').focus();
	}else{
		credentials(component);
		return false;
	}
	return true;
}

function checkEvent(event, keyCodeEnter, component) {
    if (event.keyCode == keyCodeEnter) {
        event.preventDefault();
        event.cancelBubble = true;
        return validate(component);
    }
    return true;
}

function initLoginAction(){
	document.getElementById('password').value = empty;
	document.getElementById('username').value = empty;
	document.getElementById('username').focus();
	return false;
}